package com.ruoyi.web.controller.borehole;

import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.validate.QueryGroup;
import com.ruoyi.web.domain.PostCheckBill;
import com.ruoyi.web.domain.query.AddPostCheckQuery;
import com.ruoyi.web.domain.query.PostCheckPageQuery;
import com.ruoyi.web.domain.vo.PostCheckVO;
import com.ruoyi.web.service.BhPostCheckService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@Tag(name = "岗位检查-PC端")
@RestController
@RequestMapping("/postCheck")
public class PostCheckController {
    @Autowired
    private BhPostCheckService bhPostCheckService;

    @Operation(summary = "岗位检查列表页 - 分页查询")
    @GetMapping("/getPostCheckPage")
    public TableDataInfo<PostCheckVO> getPostCheckPage(@Validated(QueryGroup.class) PostCheckPageQuery postCheckPageQuery, PageQuery pageQuery) {
        return bhPostCheckService.getPostCheckPage(postCheckPageQuery, pageQuery);
    }

    @Operation(summary = "岗位检查详情")
    @GetMapping("/getPostCheckDetail")
    public R<PostCheckVO> getPostCheckDetail(@RequestParam("id") Integer id) {
        return bhPostCheckService.getPostCheckDetail(id);
    }

    @Operation(summary = "整改岗位检查")
    @RepeatSubmit
    @PostMapping("/modPostCheck")
    public R<Void> modPostCheck(@RequestBody AddPostCheckQuery addPostCheckQuery) {
        return bhPostCheckService.modPostCheck(addPostCheckQuery);
    }

    @Operation(summary = "岗位检查-获取隐患列表")
    @GetMapping("/getDangerList")
    public R<List<PostCheckBill>> getDangerList(@RequestParam("id") Integer id) {
        return bhPostCheckService.getDangerList(id);
    }
}
